package org.cunamas.web.controller;

import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.cunamas.core.bean.BudgetInputBean;
import org.cunamas.core.bean.GeneralDataLoadErrorBean;
import org.cunamas.core.service.DataLoadService;
import org.cunamas.web.util.CunamasConstants;
import org.cunamas.web.util.FileLoad;
import org.cunamas.web.util.MessagesView;
import org.richfaces.event.UploadEvent;
import org.richfaces.model.UploadItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BudgetInputDataLoadController {
	
	@Autowired
	private DataLoadService dataLoadService;
    
    private boolean flagLoaded;
    
	private ArrayList<FileLoad> filesBudgetInput = null;
    private int uploadsAvailableBudgetInput = CunamasConstants.TOTAL_UPLOADS_AVAILABLE;
    private String messageErrorBudgetInput;
    private String messageInfoBudgetInput;
    private FileLoad fileLoadBudgetInput = new FileLoad();

	private ArrayList<FileLoad> filesGoalsInput = null;
    private int uploadsAvailableGoalsInput = CunamasConstants.TOTAL_UPLOADS_AVAILABLE;
    private String messageErrorGoalsInput;
    private String messageInfoGoalsInput;
    private FileLoad fileLoadGoalsInput = new FileLoad();

	private ArrayList<FileLoad> filesQatariInput = null;
    private int uploadsAvailableQatariInput = CunamasConstants.TOTAL_UPLOADS_AVAILABLE;
    private String messageErrorQatariInput;
    private String messageInfoQatariInput;
    private FileLoad fileLoadQatariInput = new FileLoad();

	private ArrayList<FileLoad> filesWwiInput = null;
    private int uploadsAvailableWwiInput = CunamasConstants.TOTAL_UPLOADS_AVAILABLE;
    private String messageErrorWwiInput;
    private String messageInfoWwiInput;
    private FileLoad fileLoadWwiInput = new FileLoad();

	private ArrayList<FileLoad> filesSafInput = null;
    private int uploadsAvailableSafInput = CunamasConstants.TOTAL_UPLOADS_AVAILABLE;
    private String messageErrorSafInput;
    private String messageInfoSafInput;
    private FileLoad fileLoadSafInput = new FileLoad();
    
    private Long anio;
    private Long mes;

	private List<GeneralDataLoadErrorBean> generalDataLoadErrorBeanList;
	private boolean validForm;
	
	private String messageError;
	
	private Map<String,String> listaDepartamentos;
	private Map<String,String> listaProvincias;
    
    public void loadDefaultValues(){
//    	if(flagLoaded) return;
    	
    	generalDataLoadErrorBeanList = null;
    	
    	anio = null;
    	mes = null;
    	
    	filesBudgetInput = new ArrayList<FileLoad>();
    	messageErrorBudgetInput = null;
    	messageInfoBudgetInput = null;
    	
    	filesGoalsInput = new ArrayList<FileLoad>();
    	messageErrorGoalsInput = null;
    	messageInfoGoalsInput = null;
    	
    	filesQatariInput = new ArrayList<FileLoad>();
    	messageErrorQatariInput = null;
    	messageInfoQatariInput = null;
    	
    	filesWwiInput = new ArrayList<FileLoad>();
    	messageErrorWwiInput = null;
    	messageInfoWwiInput = null;
    	
    	filesSafInput = new ArrayList<FileLoad>();
    	messageErrorSafInput = null;
    	messageInfoSafInput = null;
    	
    	messageError = null;
    	validForm = false;
    	
    	listaDepartamentos = dataLoadService.loadListaDepartamentos();
    	listaProvincias = dataLoadService.loadListaProvincias();
    	
//    	flagLoaded = true;
    }
    
    public void listenerBudgetInput(UploadEvent event) throws Exception{
        UploadItem item = event.getUploadItem();
        FileLoad file = new FileLoad();
        file.setLength(item.getData().length);
        file.setFileName(item.getFileName());
        file.setData(item.getData());
        
        int index = file.getFileName().lastIndexOf(".");
        file.setName(file.getFileName().substring(0,index));
        
        String extension = file.getFileName().substring(file.getFileName().lastIndexOf(".")+1, file.getFileName().length());
        file.setExtension(extension);
        
        ByteArrayInputStream bis = new ByteArrayInputStream(item.getData());
        file.setUploadedFile(bis);
        
        if(filesBudgetInput==null) filesBudgetInput = new ArrayList<FileLoad>();
        filesBudgetInput.add(file);
        
        uploadsAvailableBudgetInput--;
    }  
      
    public String clearUploadDataBudgetInput() {
    	filesBudgetInput.clear();
        uploadsAvailableBudgetInput = 1;
        return null;
    }
    
    
    public void listenerGoalsInput(UploadEvent event) throws Exception{
        UploadItem item = event.getUploadItem();
        FileLoad file = new FileLoad();
        file.setLength(item.getData().length);
        file.setFileName(item.getFileName());
        file.setData(item.getData());
        
        int index = file.getFileName().lastIndexOf(".");
        file.setName(file.getFileName().substring(0,index));
        
        String extension = file.getFileName().substring(file.getFileName().lastIndexOf(".")+1, file.getFileName().length());
        file.setExtension(extension);
        
        ByteArrayInputStream bis = new ByteArrayInputStream(item.getData());
        file.setUploadedFile(bis);
        
        if(filesGoalsInput==null) filesGoalsInput = new ArrayList<FileLoad>();
        filesGoalsInput.add(file);
        
        uploadsAvailableGoalsInput--;
    }  
      
    public String clearUploadDataGoalsInput() {
    	filesGoalsInput.clear();
        uploadsAvailableGoalsInput = 1;
        return null;
    }
    
    
    public void listenerQatariInput(UploadEvent event) throws Exception{
        UploadItem item = event.getUploadItem();
        FileLoad file = new FileLoad();
        file.setLength(item.getData().length);
        file.setFileName(item.getFileName());
        file.setData(item.getData());
        
        int index = file.getFileName().lastIndexOf(".");
        file.setName(file.getFileName().substring(0,index));
        
        String extension = file.getFileName().substring(file.getFileName().lastIndexOf(".")+1, file.getFileName().length());
        file.setExtension(extension);
        
        ByteArrayInputStream bis = new ByteArrayInputStream(item.getData());
        file.setUploadedFile(bis);
        
        if(filesQatariInput==null) filesQatariInput = new ArrayList<FileLoad>();
        filesQatariInput.add(file);
        
        uploadsAvailableQatariInput--;
    }  
      
    public String clearUploadDataQatariInput() {
    	filesQatariInput.clear();
        uploadsAvailableQatariInput = 1;
        return null;
    }
    
    
    public void listenerWwiInput(UploadEvent event) throws Exception{
        UploadItem item = event.getUploadItem();
        FileLoad file = new FileLoad();
        file.setLength(item.getData().length);
        file.setFileName(item.getFileName());
        file.setData(item.getData());
        
        int index = file.getFileName().lastIndexOf(".");
        file.setName(file.getFileName().substring(0,index));
        
        String extension = file.getFileName().substring(file.getFileName().lastIndexOf(".")+1, file.getFileName().length());
        file.setExtension(extension);
        
        ByteArrayInputStream bis = new ByteArrayInputStream(item.getData());
        file.setUploadedFile(bis);
        
        if(filesWwiInput==null) filesWwiInput = new ArrayList<FileLoad>();
        filesWwiInput.add(file);
        
        uploadsAvailableWwiInput--;
    }  
      
    public String clearUploadDataWwiInput() {
    	filesWwiInput.clear();
        uploadsAvailableWwiInput = 1;
        return null;
    }
    
    
    
    public void listenerSafInput(UploadEvent event) throws Exception{
        UploadItem item = event.getUploadItem();
        FileLoad file = new FileLoad();
        file.setLength(item.getData().length);
        file.setFileName(item.getFileName());
        file.setData(item.getData());
        
        int index = file.getFileName().lastIndexOf(".");
        file.setName(file.getFileName().substring(0,index));
        
        String extension = file.getFileName().substring(file.getFileName().lastIndexOf(".")+1, file.getFileName().length());
        file.setExtension(extension);
        
        ByteArrayInputStream bis = new ByteArrayInputStream(item.getData());
        file.setUploadedFile(bis);
        
        if(filesSafInput==null) filesSafInput = new ArrayList<FileLoad>();
        filesSafInput.add(file);
        
        uploadsAvailableSafInput--;
    }  
      
    public String clearUploadDataSafInput() {
    	filesSafInput.clear();
        uploadsAvailableSafInput = 1;
        return null;
    }
    
    public void validate(){
    	validForm = true;
    	messageError = null;
    	
    	if(anio==null || anio.equals(0L)){
    		messageError = MessagesView.getI18nMessage("general.anio.null");
    		validForm = false;
    		return;
    	}
    	
    	if(mes==null || mes.equals(0L)){
    		messageError = MessagesView.getI18nMessage("general.mes.null");
    		validForm = false;
    		return;
    	}
    }
    
	public void validateDataInput(boolean onlyValidateData, String inputType) {
		if(inputType==null) return;
		
		if(inputType.compareTo("1")==0){
			if (this.validateFileBudgetInput()) {
				this.readFileBudgetInput(onlyValidateData);
			}
			return;
		}
		
		if(inputType.compareTo("2")==0){
			if (this.validateFileGoalsInput()) {
				this.readFileGoalsInput(onlyValidateData);
			}
			return;
		}
		
		if(inputType.compareTo("3")==0){
			if (this.validateFileQatariInput()) {
				this.readFileQatariInput(onlyValidateData);
			}
			return;
		}
		
		if(inputType.compareTo("4")==0){
			if (this.validateFileWwiInput()) {
				this.readFileWwiInput(onlyValidateData);
			}
			return;
		}
		
//		if(inputType.compareTo("5")==0){
//			if (this.validateFileSafInput()) {
//				this.readFileSafInput(onlyValidateData);
//			}
//			return;
//		}
	}


	private boolean validateFileBudgetInput() {
		messageErrorBudgetInput = null;
		messageInfoBudgetInput = null;
		
		String extension = null;
		
		if(filesBudgetInput==null || filesBudgetInput.size()==0) return false;
		fileLoadBudgetInput = filesBudgetInput.get(0);
		
		if(fileLoadBudgetInput.getFileName() != null && fileLoadBudgetInput.getFileName().trim().length()>1) {
			// validar extension
			extension = fileLoadBudgetInput.getExtension();
			
			if(extension != null && extension.toUpperCase().equals(CunamasConstants.DATA_LOAD_EXTENSION_FILE)) {
				if(!fileLoadBudgetInput.isFileExist()){
					fileLoadBudgetInput.setPrearchivo(CunamasConstants.DATA_LOAD_INPUT_ROUTE);
					fileLoadBudgetInput.setFileName(fileLoadBudgetInput.getName() + fileLoadBudgetInput.getExtension() + System.currentTimeMillis());
					if(!fileLoadBudgetInput.saveToDisk()){
						messageErrorBudgetInput = MessagesView.getI18nMessage("general.dataLoad.validate.copy.error");
						return false;
					}
				}
			}
			else{
				messageErrorBudgetInput = MessagesView.getI18nMessage("general.validate.extension.error");
				return false;
			}
		}
		else{
			messageErrorBudgetInput = MessagesView.getI18nMessage("general.dataLoad.validate.file.null");
			return false;
		}
		
		return true;
	}
	
	private boolean validateFileGoalsInput() {
		messageErrorGoalsInput = null;
		messageInfoGoalsInput = null;
		
		String extension = null;
		
		if(filesGoalsInput==null || filesGoalsInput.size()==0) return false;
		fileLoadGoalsInput = filesGoalsInput.get(0);
		
		if(fileLoadGoalsInput.getFileName() != null && fileLoadGoalsInput.getFileName().trim().length()>1) {
			// validar extension
			extension = fileLoadGoalsInput.getExtension();
			
			if(extension != null && extension.toUpperCase().equals(CunamasConstants.DATA_LOAD_EXTENSION_FILE)) {
				if(!fileLoadGoalsInput.isFileExist()){
					fileLoadGoalsInput.setPrearchivo(CunamasConstants.DATA_LOAD_INPUT_ROUTE);
					fileLoadGoalsInput.setFileName(fileLoadGoalsInput.getName() + fileLoadGoalsInput.getExtension() + System.currentTimeMillis());
					if(!fileLoadGoalsInput.saveToDisk()){
						messageErrorGoalsInput = MessagesView.getI18nMessage("general.dataLoad.validate.copy.error");
						return false;
					}
				}
			}
			else{
				messageErrorGoalsInput = MessagesView.getI18nMessage("general.validate.extension.error");
				return false;
			}
		}
		else{
			messageErrorGoalsInput = MessagesView.getI18nMessage("general.dataLoad.validate.file.null");
			return false;
		}
		
		return true;
	}
	
	private boolean validateFileQatariInput() {
		messageErrorQatariInput = null;
		messageInfoQatariInput = null;
		
		String extension = null;
		
		if(filesQatariInput==null || filesQatariInput.size()==0) return false;
		fileLoadQatariInput = filesQatariInput.get(0);
		
		if(fileLoadQatariInput.getFileName() != null && fileLoadQatariInput.getFileName().trim().length()>1) {
			// validar extension
			extension = fileLoadQatariInput.getExtension();
			
			if(extension != null && extension.toUpperCase().equals(CunamasConstants.DATA_LOAD_EXTENSION_FILE)) {
				if(!fileLoadQatariInput.isFileExist()){
					fileLoadQatariInput.setPrearchivo(CunamasConstants.DATA_LOAD_INPUT_ROUTE);
					fileLoadQatariInput.setFileName(fileLoadQatariInput.getName() + fileLoadQatariInput.getExtension() + System.currentTimeMillis());
					if(!fileLoadQatariInput.saveToDisk()){
						messageErrorQatariInput = MessagesView.getI18nMessage("general.dataLoad.validate.copy.error");
						return false;
					}
				}
			}
			else{
				messageErrorQatariInput = MessagesView.getI18nMessage("general.validate.extension.error");
				return false;
			}
		}
		else{
			messageErrorQatariInput = MessagesView.getI18nMessage("general.dataLoad.validate.file.null");
			return false;
		}
		
		return true;
	}
	
	private boolean validateFileWwiInput() {
		messageErrorWwiInput = null;
		messageInfoWwiInput = null;
		
		String extension = null;
		
		if(filesWwiInput==null || filesWwiInput.size()==0) return false;
		fileLoadWwiInput = filesWwiInput.get(0);
		
		if(fileLoadWwiInput.getFileName() != null && fileLoadWwiInput.getFileName().trim().length()>1) {
			// validar extension
			extension = fileLoadWwiInput.getExtension();
			
			if(extension != null && extension.toUpperCase().equals(CunamasConstants.DATA_LOAD_EXTENSION_FILE)) {
				if(!fileLoadWwiInput.isFileExist()){
					fileLoadWwiInput.setPrearchivo(CunamasConstants.DATA_LOAD_INPUT_ROUTE);
					fileLoadWwiInput.setFileName(fileLoadWwiInput.getName() + fileLoadWwiInput.getExtension() + System.currentTimeMillis());
					if(!fileLoadWwiInput.saveToDisk()){
						messageErrorWwiInput = MessagesView.getI18nMessage("general.dataLoad.validate.copy.error");
						return false;
					}
				}
			}
			else{
				messageErrorWwiInput = MessagesView.getI18nMessage("general.validate.extension.error");
				return false;
			}
		}
		else{
			messageErrorWwiInput = MessagesView.getI18nMessage("general.dataLoad.validate.file.null");
			return false;
		}
		
		return true;
	}
	
	private boolean validateFileSafInput() {
		messageErrorSafInput = null;
		messageInfoSafInput = null;
		
		String extension = null;
		
		if(filesSafInput==null || filesSafInput.size()==0) return false;
		fileLoadSafInput = filesSafInput.get(0);
		
		if(fileLoadSafInput.getFileName() != null && fileLoadSafInput.getFileName().trim().length()>1) {
			// validar extension
			extension = fileLoadSafInput.getExtension();
			
			if(extension != null && extension.toUpperCase().equals(CunamasConstants.DATA_LOAD_EXTENSION_FILE)) {
				if(!fileLoadSafInput.isFileExist()){
					fileLoadSafInput.setPrearchivo(CunamasConstants.DATA_LOAD_INPUT_ROUTE);
					fileLoadSafInput.setFileName(fileLoadSafInput.getName() + fileLoadSafInput.getExtension() + System.currentTimeMillis());
					if(!fileLoadSafInput.saveToDisk()){
						messageErrorSafInput = MessagesView.getI18nMessage("general.dataLoad.validate.copy.error");
						return false;
					}
				}
			}
			else{
				messageErrorSafInput = MessagesView.getI18nMessage("general.validate.extension.error");
				return false;
			}
		}
		else{
			messageErrorSafInput = MessagesView.getI18nMessage("general.dataLoad.validate.file.null");
			return false;
		}
		
		return true;
	}
	
	
	private void readFileBudgetInput(boolean onlyValidateData) {
		List<BudgetInputBean> budgetInputProgrammedBeanList = new ArrayList<BudgetInputBean>();
		List<BudgetInputBean> budgetInputExecutedBeanList = new ArrayList<BudgetInputBean>();
		
		POIFSFileSystem poifsFileSystem = null;
		
		messageErrorBudgetInput = null;
		messageInfoBudgetInput = null;
		String errorDataPNCM = null;
		String errorDataProgramaEjecutado = null;
		
		if(fileLoadBudgetInput==null) return;
		
		try {
			FileInputStream  fileIn = new FileInputStream(fileLoadBudgetInput.getPrearchivo() + fileLoadBudgetInput.getFileName());
			poifsFileSystem = new POIFSFileSystem(fileIn);
		}
		catch (FileNotFoundException ex) {
			ex.printStackTrace();
		}
		catch (IOException ex) {
			ex.printStackTrace();
		}
		
		HSSFWorkbook workbook;
		
		generalDataLoadErrorBeanList = new ArrayList<GeneralDataLoadErrorBean>();
		
		
		try {
			workbook = new HSSFWorkbook(poifsFileSystem);
			
			getDataPNCM(workbook, budgetInputProgrammedBeanList);
//			getDataProgramaEjecutado(workbook, budgetInputExecutedBeanList);
			
			if (!onlyValidateData) {
				if (generalDataLoadErrorBeanList.size() == 0) {
					System.out.println("procesando datos pncm = "+budgetInputProgrammedBeanList.size());
//					System.out.println("procesando datos programado - ejecutado = "+budgetInputExecutedBeanList.size());
					errorDataPNCM = dataLoadService.processBudgetInputProgrammedDataLoad(anio, mes, budgetInputProgrammedBeanList);
//					errorDataProgramaEjecutado = dataLoadService.processBudgetInputExecutedDataLoad(anio, mes, budgetInputExecutedBeanList);
					if(errorDataPNCM==null && errorDataProgramaEjecutado==null){
						messageInfoBudgetInput = MessagesView.getI18nMessage("general.validate.fileProcessed");
					}
//					else{
//						messageErrorBudgetInput = errorDataPNCM==null ? "" : errorDataPNCM + 
//								errorDataProgramaEjecutado==null ? "" : errorDataProgramaEjecutado;
//					}
				}
			}
			else {
				if (generalDataLoadErrorBeanList == null || generalDataLoadErrorBeanList.size() == 0) {
					System.out.println("validando datos pncm = "+budgetInputProgrammedBeanList.size());
//					System.out.println("validando datos programado - ejecutado = "+budgetInputExecutedBeanList.size());
					messageInfoBudgetInput = MessagesView.getI18nMessage("general.validateFile.sucessfull");
				}
			}
		}
		catch (Exception ex) {
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}
	
	private void getDataPNCM(HSSFWorkbook workbook,List<BudgetInputBean> budgetInputBeanList){
		String departamento = null;
		String provincia = null;
		String intervenciones = null;
		BigDecimal presupuestoTotalProgramado = null;
		BigDecimal presupuestoTotalEjecutado = null;
		
		BudgetInputBean budgetInputBean = null;
		
		boolean sinContenido = false;
		
		try{
			HSSFSheet sheet = workbook.getSheetAt(1); // workbook.getSheet("PNCM"); 
			for(int i=7;i<sheet.getPhysicalNumberOfRows() && !sinContenido ;i++){
				
				Row row=sheet.getRow(i);

				Cell numeroCell = row.getCell(1);
				Cell intervencionesCell = row.getCell(4);
				Cell departamentoCell = row.getCell(5);
				Cell provinciaCell = row.getCell(6);
				Cell presupuestoTotalProgramadoCell = row.getCell(8);
				Cell presupuestoTotalEjecutadoCell = row.getCell(9);
				
				budgetInputBean = new BudgetInputBean();
				budgetInputBean.setAnio(this.anio);
				budgetInputBean.setMes(this.mes);
				
				if (!(numeroCell != null && numeroCell.getCellType() == Cell.CELL_TYPE_NUMERIC)) {
					sinContenido = true;
					continue;
				}
				
				if (intervencionesCell != null && intervencionesCell.getCellType() == Cell.CELL_TYPE_STRING) {
					intervenciones = intervencionesCell.getStringCellValue().toUpperCase();
					budgetInputBean.setIntervenciones(intervenciones);
				}
				
				if (departamentoCell != null && departamentoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					departamento = departamentoCell.getStringCellValue().toUpperCase();
					
					if(listaDepartamentos.containsKey(departamento)){
						departamento = listaDepartamentos.get(departamento);
					}
					
					budgetInputBean.setDepartamento(departamento);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.departamentoNoExist"));
				}
				
				if (provinciaCell != null && provinciaCell.getCellType() == Cell.CELL_TYPE_STRING) {
					provincia = provinciaCell.getStringCellValue().toUpperCase();

					if(listaProvincias.containsKey(departamento+"_"+provincia)){
						provincia = listaProvincias.get(departamento+"_"+provincia);
					}
					
					budgetInputBean.setProvincia(provincia);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.provinciaNoExist"));
				}
				
				
				if (presupuestoTotalProgramadoCell != null && presupuestoTotalProgramadoCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
					presupuestoTotalProgramado = new BigDecimal(presupuestoTotalProgramadoCell.getNumericCellValue());
					budgetInputBean.setPresupuestoTotalProgramado(presupuestoTotalProgramado);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoTotalProgramadoNoExist"));
				}
				
				if (presupuestoTotalEjecutadoCell != null && presupuestoTotalEjecutadoCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
					presupuestoTotalEjecutado = new BigDecimal(presupuestoTotalEjecutadoCell.getNumericCellValue());
					budgetInputBean.setPresupuestoTotalEjecutado(presupuestoTotalEjecutado);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoTotalEjecutadoNoExist"));
				}
				
				budgetInputBeanList.add(budgetInputBean);

			}
		}
		catch(Exception ex){
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}
	
	private void getDataProgramaEjecutado(HSSFWorkbook workbook,List<BudgetInputBean> budgetInputBeanList){
		String departamento = null;
		String provincia = null;
		
		String departamentoAnterior = null;
		
		BigDecimal presupuestoProgramadoExCunamasCuidadoDiurno = BigDecimal.ZERO;
		BigDecimal presupuestoProgramadoExCunamasQatari = BigDecimal.ZERO;
		BigDecimal presupuestoProgramadoExCunamasWwi = BigDecimal.ZERO;
		BigDecimal presupuestoProgramadoCunamasSaf = BigDecimal.ZERO;
		BigDecimal presupuestoProgramadoCunamasCuidadoDiurno = BigDecimal.ZERO;
		
		BigDecimal presupuestoEjecutadoExCunamasCuidadoDiurno = BigDecimal.ZERO;
		BigDecimal presupuestoEjecutadoExCunamasQatari = BigDecimal.ZERO;
		BigDecimal presupuestoEjecutadoExCunamasWwi = BigDecimal.ZERO;
		BigDecimal presupuestoEjecutadoCunamasSaf = BigDecimal.ZERO;
		BigDecimal presupuestoEjecutadoCunamasCuidadoDiurno = BigDecimal.ZERO;
		
		boolean sinContenido = false;
		
		BudgetInputBean budgetInputBean = null;
		
		try{
			HSSFSheet sheet = workbook.getSheetAt(0); // workbook.getSheet("PROGRAMADO-EJECUTADO"); 
			for(int i=5;i<sheet.getPhysicalNumberOfRows() && !sinContenido;i++){
				
				Row row=sheet.getRow(i);

				Cell departamentoCell = row.getCell(0);
				Cell provinciaCell = row.getCell(1);
				Cell presupuestoProgramadoExCunamasCuidadoDiurnoCell = row.getCell(3);
				Cell presupuestoProgramadoExCunamasQatariCell = row.getCell(4);
				Cell presupuestoProgramadoExCunamasWwiCell = row.getCell(6);
				Cell presupuestoProgramadoCunamasSafCell = row.getCell(5);
				Cell presupuestoProgramadoCunamasCuidadoDiurnoCell = row.getCell(5);
				Cell presupuestoEjecutadoExCunamasCuidadoDiurnoCell = row.getCell(8);
				Cell presupuestoEjecutadoExCunamasQatariCell = row.getCell(9);
				Cell presupuestoEjecutadoExCunamasWwiCell = row.getCell(11);
//				Cell presupuestoEjecutadoCunamasSafCell = row.getCell();
				Cell presupuestoEjecutadoCunamasCuidadoDiurnoCell = row.getCell(10);
				
				budgetInputBean = new BudgetInputBean();
				budgetInputBean.setAnio(this.anio);
				budgetInputBean.setMes(this.mes);
				
				if (departamentoCell != null && departamentoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					departamento = departamentoCell.getStringCellValue().toUpperCase();

					if(listaDepartamentos.containsKey(departamento)){
						departamento = listaDepartamentos.get(departamento);
					}
					
					budgetInputBean.setDepartamento(departamento);
					departamentoAnterior = departamento;
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.departamentoNoExist"));
					budgetInputBean.setDepartamento(departamentoAnterior);
				}
				
				if (provinciaCell != null && provinciaCell.getCellType() == Cell.CELL_TYPE_STRING) {
					provincia = provinciaCell.getStringCellValue().toUpperCase();
					
					if(listaProvincias.containsKey(departamento+"_"+provincia)){
						provincia = listaProvincias.get(departamento+"_"+provincia);
					}
					
					budgetInputBean.setProvincia(provincia);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.provinciaNoExist"));
					sinContenido = true;
					continue;
				}
				
				
				if (presupuestoProgramadoExCunamasCuidadoDiurnoCell != null && (
						presupuestoProgramadoExCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_NUMERIC || 
						presupuestoProgramadoExCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_BLANK)) {
					
					if(presupuestoProgramadoExCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_BLANK){
						presupuestoProgramadoExCunamasCuidadoDiurno = BigDecimal.ZERO;
					}
					else{
						presupuestoProgramadoExCunamasCuidadoDiurno = new BigDecimal(presupuestoProgramadoExCunamasCuidadoDiurnoCell.getNumericCellValue());						
					}
					budgetInputBean.setPresupuestoProgramadoExCunamasCuidadoDiurno(presupuestoProgramadoExCunamasCuidadoDiurno);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoProgramadoExCunamasCuidadoDiurnoNoExist"));
				}
				
				if (presupuestoProgramadoExCunamasQatariCell != null && (
						presupuestoProgramadoExCunamasQatariCell.getCellType() == Cell.CELL_TYPE_NUMERIC || 
						presupuestoProgramadoExCunamasQatariCell.getCellType() == Cell.CELL_TYPE_BLANK)) {
					
					if(presupuestoProgramadoExCunamasQatariCell.getCellType() == Cell.CELL_TYPE_BLANK){
						presupuestoProgramadoExCunamasQatari = BigDecimal.ZERO;
					}
					else{
						presupuestoProgramadoExCunamasQatari = new BigDecimal(presupuestoProgramadoExCunamasQatariCell.getNumericCellValue());	
					}
					budgetInputBean.setPresupuestoProgramadoExCunamasQatari(presupuestoProgramadoExCunamasQatari);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoProgramadoExCunamasQatariNoExist"));
				}
				
				if (presupuestoProgramadoExCunamasWwiCell != null && (
						presupuestoProgramadoExCunamasWwiCell.getCellType() == Cell.CELL_TYPE_NUMERIC || 
						presupuestoProgramadoExCunamasWwiCell.getCellType() == Cell.CELL_TYPE_BLANK)) {
					
					if(presupuestoProgramadoExCunamasWwiCell.getCellType() == Cell.CELL_TYPE_BLANK){
						presupuestoProgramadoExCunamasWwi = BigDecimal.ZERO;
					}
					else{
						presupuestoProgramadoExCunamasWwi = new BigDecimal(presupuestoProgramadoExCunamasWwiCell.getNumericCellValue());	
					}
					budgetInputBean.setPresupuestoProgramadoExCunamasWwi(presupuestoProgramadoExCunamasWwi);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoProgramadoExCunamasWwiNoExist"));
				}
				
				if (presupuestoProgramadoCunamasSafCell != null && (
						presupuestoProgramadoCunamasSafCell.getCellType() == Cell.CELL_TYPE_NUMERIC || 
						presupuestoProgramadoCunamasSafCell.getCellType() == Cell.CELL_TYPE_BLANK)) {
					
					if(presupuestoProgramadoCunamasSafCell.getCellType() == Cell.CELL_TYPE_BLANK){
						presupuestoProgramadoCunamasSaf = BigDecimal.ZERO;
					}
					else{
						presupuestoProgramadoCunamasSaf = new BigDecimal(presupuestoProgramadoCunamasSafCell.getNumericCellValue());	
					}
					budgetInputBean.setPresupuestoProgramadoCunamasSaf(presupuestoProgramadoCunamasSaf);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoProgramadoCunamasSafNoExist"));
				}
				
				if (presupuestoProgramadoCunamasCuidadoDiurnoCell != null && (
						presupuestoProgramadoCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_NUMERIC || 
						presupuestoProgramadoCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_BLANK)) {
					
					if(presupuestoProgramadoCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_BLANK){
						presupuestoProgramadoCunamasCuidadoDiurno = BigDecimal.ZERO;
					}
					else{
						presupuestoProgramadoCunamasCuidadoDiurno = new BigDecimal(presupuestoProgramadoCunamasCuidadoDiurnoCell.getNumericCellValue());	
					}
					budgetInputBean.setPresupuestoProgramadoCunamasCuidadoDiurno(presupuestoProgramadoCunamasCuidadoDiurno);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoProgramadoCunamasCuidadoDiurnoNoExist"));
				}
				

				
				if (presupuestoEjecutadoExCunamasCuidadoDiurnoCell != null && (
						presupuestoEjecutadoExCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_NUMERIC || 
						presupuestoEjecutadoExCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_BLANK)) {
					
					if(presupuestoEjecutadoExCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_BLANK){
						presupuestoEjecutadoExCunamasCuidadoDiurno = BigDecimal.ZERO;
					}
					else{
						presupuestoEjecutadoExCunamasCuidadoDiurno = new BigDecimal(presupuestoEjecutadoExCunamasCuidadoDiurnoCell.getNumericCellValue());	
					}
					budgetInputBean.setPresupuestoEjecutadoExCunamasCuidadoDiurno(presupuestoEjecutadoExCunamasCuidadoDiurno);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoEjecutadoExCunamasCuidadoDiurnoNoExist"));
				}
				
				if (presupuestoEjecutadoExCunamasQatariCell != null && (
						presupuestoEjecutadoExCunamasQatariCell.getCellType() == Cell.CELL_TYPE_NUMERIC || 
						presupuestoEjecutadoExCunamasQatariCell.getCellType() == Cell.CELL_TYPE_BLANK)) {
					
					if(presupuestoEjecutadoExCunamasQatariCell.getCellType() == Cell.CELL_TYPE_BLANK){
						presupuestoEjecutadoExCunamasQatari = BigDecimal.ZERO;
					}
					else{
						presupuestoEjecutadoExCunamasQatari = new BigDecimal(presupuestoEjecutadoExCunamasQatariCell.getNumericCellValue());	
					}
					budgetInputBean.setPresupuestoEjecutadoExCunamasQatari(presupuestoEjecutadoExCunamasQatari);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoEjecutadoExCunamasQatariNoExist"));
				}
				
				if (presupuestoEjecutadoExCunamasWwiCell != null && (
						presupuestoEjecutadoExCunamasWwiCell.getCellType() == Cell.CELL_TYPE_NUMERIC || 
						presupuestoEjecutadoExCunamasWwiCell.getCellType() == Cell.CELL_TYPE_BLANK)) {
					
					if(presupuestoEjecutadoExCunamasWwiCell.getCellType() == Cell.CELL_TYPE_BLANK){
						presupuestoEjecutadoExCunamasWwi = BigDecimal.ZERO;
					}
					else{
						presupuestoEjecutadoExCunamasWwi = new BigDecimal(presupuestoEjecutadoExCunamasWwiCell.getNumericCellValue());
					}
					budgetInputBean.setPresupuestoEjecutadoExCunamasWwi(presupuestoEjecutadoExCunamasWwi);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoEjecutadoExCunamasWwiNoExist"));
				}
				
//				if (presupuestoEjecutadoCunamasSafCell != null && presupuestoEjecutadoCunamasSafCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
//					presupuestoEjecutadoCunamasSaf = new BigDecimal(presupuestoEjecutadoCunamasSafCell.getNumericCellValue());
					budgetInputBean.setPresupuestoEjecutadoCunamasSaf(presupuestoEjecutadoCunamasSaf);
//				}
//				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoEjecutadoCunamasSafNoExist"));
//				}
				
				if (presupuestoEjecutadoCunamasCuidadoDiurnoCell != null && (
						presupuestoEjecutadoCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_NUMERIC || 
						presupuestoEjecutadoCunamasCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_BLANK)) {
					
					if(presupuestoEjecutadoExCunamasWwiCell.getCellType() == Cell.CELL_TYPE_BLANK){
						presupuestoEjecutadoCunamasCuidadoDiurno = BigDecimal.ZERO;
					}
					else{
						presupuestoEjecutadoCunamasCuidadoDiurno = new BigDecimal(presupuestoEjecutadoCunamasCuidadoDiurnoCell.getNumericCellValue());
					}
					
					budgetInputBean.setPresupuestoEjecutadoCunamasCuidadoDiurno(presupuestoEjecutadoCunamasCuidadoDiurno);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.presupuestoEjecutadoCunamasCuidadoDiurnoNoExist"));
				}
				
				budgetInputBeanList.add(budgetInputBean);

			}
		}
		catch(Exception ex){
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}
	
	private void readFileGoalsInput(boolean onlyValidateData) {
		List<BudgetInputBean> goalsInputCuidadoDiurnoBeanList = new ArrayList<BudgetInputBean>();
		List<BudgetInputBean> goalsInputQatariBeanList = new ArrayList<BudgetInputBean>();
		List<BudgetInputBean> goalsInputWwiBeanList = new ArrayList<BudgetInputBean>();
		List<BudgetInputBean> goalsInputSafBeanList = new ArrayList<BudgetInputBean>();
		
		POIFSFileSystem poifsFileSystem = null;
		
		messageErrorGoalsInput = null;
		messageInfoGoalsInput = null;
		String errorDataCuidadoDiurno = null;
		String errorDataQatari = null;
		String errorDataWwi = null;
		String errorDataSaf = null;

		if(fileLoadGoalsInput==null) return;
		
		try {
			FileInputStream  fileIn = new FileInputStream(fileLoadGoalsInput.getPrearchivo() + fileLoadGoalsInput.getFileName());
			poifsFileSystem = new POIFSFileSystem(fileIn);
		}
		catch (FileNotFoundException ex) {
			ex.printStackTrace();
		}
		catch (IOException ex) {
			ex.printStackTrace();
		}
		
		HSSFWorkbook workbook;
		
		generalDataLoadErrorBeanList = new ArrayList<GeneralDataLoadErrorBean>();
		
		
		try {
			workbook = new HSSFWorkbook(poifsFileSystem);
			
			getDataCuidadoDiurno(workbook, goalsInputCuidadoDiurnoBeanList);
			getDataQatari(workbook, goalsInputQatariBeanList);
			getDataWwi(workbook, goalsInputWwiBeanList);
			getDataSaf(workbook, goalsInputSafBeanList);
			
			if (!onlyValidateData) {
				if (generalDataLoadErrorBeanList.size() == 0) {
					System.out.println("procesando datos cuidado diurno = "+goalsInputCuidadoDiurnoBeanList.size());
					System.out.println("procesando datos qatari = "+goalsInputQatariBeanList.size());
					System.out.println("procesando datos wwi = "+goalsInputWwiBeanList.size());
					System.out.println("procesando datos saf = "+goalsInputSafBeanList.size());
					
					errorDataCuidadoDiurno = dataLoadService.processGoalsInputCuidadoDiurnoDataLoad(anio, mes, goalsInputCuidadoDiurnoBeanList);
					errorDataQatari = dataLoadService.processGoalsInputQatariDataLoad(anio, mes, goalsInputQatariBeanList);
					errorDataWwi = dataLoadService.processGoalsInputWwiDataLoad(anio, mes, goalsInputWwiBeanList);
					errorDataSaf = dataLoadService.processGoalsInputSafDataLoad(anio, mes, goalsInputSafBeanList);
					
					if(errorDataCuidadoDiurno==null && errorDataQatari==null && errorDataWwi==null && errorDataSaf==null){
						messageInfoGoalsInput = MessagesView.getI18nMessage("general.validate.fileProcessed");
					}
					else{
						messageErrorGoalsInput = 
								errorDataCuidadoDiurno==null ? "" : errorDataCuidadoDiurno + 
										errorDataQatari==null ? "" : errorDataQatari +
												errorDataWwi==null ? "" : errorDataWwi +
														errorDataSaf==null ? "" : errorDataSaf;
					}
				}
			}
			else {
				if (generalDataLoadErrorBeanList == null || generalDataLoadErrorBeanList.size() == 0) {
					System.out.println("validando datos cuidado diurno = "+goalsInputCuidadoDiurnoBeanList.size());
					System.out.println("validando datos qatari = "+goalsInputQatariBeanList.size());
					System.out.println("validando datos wwi = "+goalsInputWwiBeanList.size());
					System.out.println("validando datos saf = "+goalsInputSafBeanList.size());
					messageInfoGoalsInput = MessagesView.getI18nMessage("general.validateFile.sucessfull");
				}
			}
		}
		catch (Exception ex) {
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}
	

	private void getDataCuidadoDiurno(HSSFWorkbook workbook,List<BudgetInputBean> goalsInputCuidadoDiurnoBeanList) {
		String codigoUbigeo = null;
		String departamento = null;
		String provincia = null;
		String distrito = null;
		String nombreComiteGestion = null;
		Long metaCuidadoDiurno = null;
		
		BudgetInputBean budgetInputBean = null;
		
		boolean sinContenido = false;
		
		try{
			HSSFSheet sheet = workbook.getSheetAt(0); 
			for(int i=2;i<sheet.getPhysicalNumberOfRows() && !sinContenido ;i++){
				
				Row row=sheet.getRow(i);

				Cell codigoUbigeoCell = row.getCell(2);
				Cell departamentoCell = row.getCell(3);
				Cell provinciaCell = row.getCell(4);
				Cell distritoCell = row.getCell(5);
				Cell nombreComiteGestionCell = row.getCell(6);
				Cell metaCuidadoDiurnoCell = row.getCell(9);
				
				budgetInputBean = new BudgetInputBean();
				budgetInputBean.setAnio(this.anio);
				budgetInputBean.setMes(this.mes);
				
				if (codigoUbigeoCell != null && (
						codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING || 
								codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_NUMERIC)) {
					if(codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING){
						codigoUbigeo = codigoUbigeoCell.getStringCellValue().toUpperCase();
					}
					else{
						codigoUbigeo = getUbigeoAsString((Long.valueOf((long)codigoUbigeoCell.getNumericCellValue())));
					}
					budgetInputBean.setCodigoUbigeo(codigoUbigeo);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.codigoUbigeoNoExist"));
					sinContenido = true;
					continue;
				}
				
				if (departamentoCell != null && departamentoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					departamento = departamentoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDepartamento(departamento);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.departamentoNoExist"));
				}
				
				if (provinciaCell != null && provinciaCell.getCellType() == Cell.CELL_TYPE_STRING) {
					provincia = provinciaCell.getStringCellValue().toUpperCase();
					budgetInputBean.setProvincia(provincia);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.provinciaNoExist"));
				}
				
				if (distritoCell != null && distritoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					distrito = distritoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDistrito(distrito);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.distritoNoExist"));
				}
				
				if (nombreComiteGestionCell != null && nombreComiteGestionCell.getCellType() == Cell.CELL_TYPE_STRING) {
					nombreComiteGestion = nombreComiteGestionCell.getStringCellValue().toUpperCase();
					budgetInputBean.setNombreComiteGestion(nombreComiteGestion);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.nombreComiteGestionNoExist"));
				}
				
				if (metaCuidadoDiurnoCell != null && metaCuidadoDiurnoCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
					metaCuidadoDiurno = Long.valueOf((long)metaCuidadoDiurnoCell.getNumericCellValue());
					budgetInputBean.setMetaCuidadoDiurno(metaCuidadoDiurno);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.metaCuidadoDiurnoNoExist"));
				}
				
				goalsInputCuidadoDiurnoBeanList.add(budgetInputBean);

			}
		}
		catch(Exception ex){
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}

	private String getUbigeoAsString(Long ubigeo) {
		String ubigeoText = ubigeo.toString();
		if(ubigeoText.length()==5){
			return "0" + ubigeoText;
		}
		return ubigeoText;
	}

	private void getDataQatari(HSSFWorkbook workbook,List<BudgetInputBean> goalsInputQatariBeanList) {
		String codigoUbigeo = null;
		String departamento = null;
		String provincia = null;
		String distrito = null;
		Long metaQatari = null;
		
		BudgetInputBean budgetInputBean = null;
		
		boolean sinContenido = false;
		
		try{
			HSSFSheet sheet = workbook.getSheetAt(1); 
			for(int i=1;i<sheet.getPhysicalNumberOfRows() && !sinContenido;i++){
				
				Row row=sheet.getRow(i);

				Cell codigoUbigeoCell = row.getCell(0);
				Cell departamentoCell = row.getCell(1);
				Cell provinciaCell = row.getCell(2);
				Cell distritoCell = row.getCell(3);
				Cell metaQatariCell = row.getCell(7);
				
				budgetInputBean = new BudgetInputBean();
				budgetInputBean.setAnio(this.anio);
				budgetInputBean.setMes(this.mes);
				
				if (codigoUbigeoCell != null && (
						codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING || 
								codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_NUMERIC)) {
					if(codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING){
						codigoUbigeo = codigoUbigeoCell.getStringCellValue().toUpperCase();
					}
					else{
						codigoUbigeo = getUbigeoAsString((Long.valueOf((long)codigoUbigeoCell.getNumericCellValue())));
					}
					budgetInputBean.setCodigoUbigeo(codigoUbigeo);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.codigoUbigeoNoExist"));
					sinContenido = true;
					continue;
				}
				
				if (departamentoCell != null && departamentoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					departamento = departamentoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDepartamento(departamento);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.departamentoNoExist"));
				}
				
				if (provinciaCell != null && provinciaCell.getCellType() == Cell.CELL_TYPE_STRING) {
					provincia = provinciaCell.getStringCellValue().toUpperCase();
					budgetInputBean.setProvincia(provincia);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.provinciaNoExist"));
				}
				
				if (distritoCell != null && distritoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					distrito = distritoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDistrito(distrito);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.distritoNoExist"));
					sinContenido = true;
					continue;
				}
				
				if (metaQatariCell != null && metaQatariCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
					metaQatari = Long.valueOf((long)metaQatariCell.getNumericCellValue());
					budgetInputBean.setMetaQatari(metaQatari);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.metaQatariNoExist"));
				}
				
				goalsInputQatariBeanList.add(budgetInputBean);

			}
		}
		catch(Exception ex){
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}

	private void getDataWwi(HSSFWorkbook workbook,List<BudgetInputBean> goalsInputWwiBeanList) {
		String codigoUbigeo = null;
		String departamento = null;
		String provincia = null;
		String distrito = null;
		Long metaWwi = null;
		
		BudgetInputBean budgetInputBean = null;
		
		boolean sinContenido = false;
		
		try{
			HSSFSheet sheet = workbook.getSheetAt(2); 
			for(int i=1;i<sheet.getPhysicalNumberOfRows() && !sinContenido;i++){
				
				Row row=sheet.getRow(i);

				Cell codigoUbigeoCell = row.getCell(0);
				Cell departamentoCell = row.getCell(1);
				Cell provinciaCell = row.getCell(2);
				Cell distritoCell = row.getCell(3);
				Cell metaWwiCell = row.getCell(11);
				
				budgetInputBean = new BudgetInputBean();
				budgetInputBean.setAnio(this.anio);
				budgetInputBean.setMes(this.mes);
				
				if (codigoUbigeoCell != null && (
						codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING || 
								codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_NUMERIC)) {
					if(codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING){
						codigoUbigeo = codigoUbigeoCell.getStringCellValue().toUpperCase();
					}
					else{
						codigoUbigeo = getUbigeoAsString((Long.valueOf((long)codigoUbigeoCell.getNumericCellValue())));
					}
					budgetInputBean.setCodigoUbigeo(codigoUbigeo);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.codigoUbigeoNoExist"));
					sinContenido = true;
					continue;
				}
				
				if (departamentoCell != null && departamentoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					departamento = departamentoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDepartamento(departamento);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.departamentoNoExist"));
				}
				
				if (provinciaCell != null && provinciaCell.getCellType() == Cell.CELL_TYPE_STRING) {
					provincia = provinciaCell.getStringCellValue().toUpperCase();
					budgetInputBean.setProvincia(provincia);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.provinciaNoExist"));
				}
				
				if (distritoCell != null && distritoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					distrito = distritoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDistrito(distrito);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.distritoNoExist"));
				}
				
				if (metaWwiCell != null && metaWwiCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
					metaWwi = Long.valueOf((long)metaWwiCell.getNumericCellValue());
					budgetInputBean.setMetaWwi(metaWwi);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.metaWwiNoExist"));
				}
				
				goalsInputWwiBeanList.add(budgetInputBean);

			}
		}
		catch(Exception ex){
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}

	private void getDataSaf(HSSFWorkbook workbook,List<BudgetInputBean> goalsInputSafBeanList) {
		String codigoUbigeo = null;
		String departamento = null;
		String provincia = null;
		String distrito = null;
		Long metaSaf = null;
		
		BudgetInputBean budgetInputBean = null;
		
		boolean sinContenido = false;
		
		try{
			HSSFSheet sheet = workbook.getSheetAt(3); 
			for(int i=4;i<sheet.getPhysicalNumberOfRows() && !sinContenido;i++){
				
				Row row=sheet.getRow(i);

				Cell codigoUbigeoCell = row.getCell(0);
				Cell departamentoCell = row.getCell(1);
				Cell provinciaCell = row.getCell(2);
				Cell distritoCell = row.getCell(3);
				Cell metaSafCell = row.getCell(11);
				
				budgetInputBean = new BudgetInputBean();
				budgetInputBean.setAnio(this.anio);
				budgetInputBean.setMes(this.mes);
				
				if (codigoUbigeoCell != null && (
						codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING || 
								codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_NUMERIC)) {
					if(codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING){
						codigoUbigeo = codigoUbigeoCell.getStringCellValue().toUpperCase();
					}
					else{
						codigoUbigeo = getUbigeoAsString((Long.valueOf((long)codigoUbigeoCell.getNumericCellValue())));
					}
					budgetInputBean.setCodigoUbigeo(codigoUbigeo);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.codigoUbigeoNoExist"));
					sinContenido = true;
					continue;
				}
				
				if (departamentoCell != null && departamentoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					departamento = departamentoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDepartamento(departamento);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.departamentoNoExist"));
				}
				
				if (provinciaCell != null && provinciaCell.getCellType() == Cell.CELL_TYPE_STRING) {
					provincia = provinciaCell.getStringCellValue().toUpperCase();
					budgetInputBean.setProvincia(provincia);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.provinciaNoExist"));
				}
				
				if (distritoCell != null && distritoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					distrito = distritoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDistrito(distrito);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.distritoNoExist"));
					sinContenido = true;
					continue;
				}
				
				if (metaSafCell != null && (
						metaSafCell.getCellType() == Cell.CELL_TYPE_NUMERIC || 
								metaSafCell.getCellType() == Cell.CELL_TYPE_BLANK)) {
					
					if(metaSafCell.getCellType() == Cell.CELL_TYPE_BLANK){
						metaSaf = 0L;
					}
					else{
						metaSaf = Long.valueOf((long)metaSafCell.getNumericCellValue());
					}
					budgetInputBean.setMetaSaf(metaSaf);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.metaSafNoExist"));
				}
				
				goalsInputSafBeanList.add(budgetInputBean);

			}
		}
		catch(Exception ex){
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}

	private void readFileQatariInput(boolean onlyValidateData) {
		List<BudgetInputBean> qatariInputBeanList = new ArrayList<BudgetInputBean>();
		
		POIFSFileSystem poifsFileSystem = null;
		
		messageErrorQatariInput = null;
		messageInfoQatariInput = null;
		String errorDataQatari = null;

		if(fileLoadQatariInput==null) return;
		
		try {
			FileInputStream  fileIn = new FileInputStream(fileLoadQatariInput.getPrearchivo() + fileLoadQatariInput.getFileName());
			poifsFileSystem = new POIFSFileSystem(fileIn);
		}
		catch (FileNotFoundException ex) {
			ex.printStackTrace();
		}
		catch (IOException ex) {
			ex.printStackTrace();
		}
		
		HSSFWorkbook workbook;
		
		generalDataLoadErrorBeanList = new ArrayList<GeneralDataLoadErrorBean>();
		
		
		try {
			workbook = new HSSFWorkbook(poifsFileSystem);
			
			getDataQatariInput(workbook, qatariInputBeanList);
			
			if (!onlyValidateData) {
				if (generalDataLoadErrorBeanList.size() == 0) {
					System.out.println("procesando datos qatari = "+qatariInputBeanList.size());
					
					errorDataQatari = dataLoadService.processQatariInputDataLoad(anio, mes, qatariInputBeanList);
					
					if(errorDataQatari==null){
						messageInfoQatariInput = MessagesView.getI18nMessage("general.validate.fileProcessed");
					}
					else{
						messageErrorQatariInput = errorDataQatari;
					}
				}
			}
			else {
				if (generalDataLoadErrorBeanList == null || generalDataLoadErrorBeanList.size() == 0) {
					System.out.println("validando datos qatari = "+qatariInputBeanList.size());
					messageInfoQatariInput = MessagesView.getI18nMessage("general.validateFile.sucessfull");
				}
			}
		}
		catch (Exception ex) {
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}
	
	
	private void getDataQatariInput(HSSFWorkbook workbook,List<BudgetInputBean> qatariInputBeanList) {
		String codigoUbigeo = null;
		String departamento = null;
		String provincia = null;
		String distrito = null;
		Long ejecutadoQatari = null;
		
		BudgetInputBean budgetInputBean = null;
		
		boolean sinContenido = false;
		
		try{
			HSSFSheet sheet = workbook.getSheetAt(0); 
			for(int i=1;i<sheet.getPhysicalNumberOfRows() && !sinContenido;i++){
				
				Row row=sheet.getRow(i);

				Cell codigoUbigeoCell = row.getCell(0);
				Cell departamentoCell = row.getCell(1);
				Cell provinciaCell = row.getCell(2);
				Cell distritoCell = row.getCell(3);
				Cell ejecutadoQatariCell = row.getCell(4);
				
				budgetInputBean = new BudgetInputBean();
				budgetInputBean.setAnio(this.anio);
				budgetInputBean.setMes(this.mes);
				
				if (codigoUbigeoCell != null && (
						codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING || 
								codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_NUMERIC)) {
					if(codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING){
						codigoUbigeo = codigoUbigeoCell.getStringCellValue().toUpperCase();
					}
					else{
						codigoUbigeo = getUbigeoAsString((Long.valueOf((long)codigoUbigeoCell.getNumericCellValue())));
					}
					budgetInputBean.setCodigoUbigeo(codigoUbigeo);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.codigoUbigeoNoExist"));
//					sinContenido = true;
//					continue;
					budgetInputBean.setCodigoUbigeo("");
				}
				
				if (departamentoCell != null && departamentoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					departamento = departamentoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDepartamento(departamento);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.departamentoNoExist"));
				}
				
				if (provinciaCell != null && provinciaCell.getCellType() == Cell.CELL_TYPE_STRING) {
					provincia = provinciaCell.getStringCellValue().toUpperCase();
					budgetInputBean.setProvincia(provincia);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.provinciaNoExist"));
				}
				
				if (distritoCell != null && distritoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					distrito = distritoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDistrito(distrito);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.distritoNoExist"));
				}
				
				if (ejecutadoQatariCell != null && ejecutadoQatariCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
					ejecutadoQatari = Long.valueOf((long)ejecutadoQatariCell.getNumericCellValue());
					budgetInputBean.setEjecutadoQatari(ejecutadoQatari);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.ejecutadoQatariNoExist"));
				}
				
				qatariInputBeanList.add(budgetInputBean);

			}
		}
		catch(Exception ex){
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}

	private void readFileWwiInput(boolean onlyValidateData) {
		List<BudgetInputBean> wwiInputBeanList = new ArrayList<BudgetInputBean>();
		
		POIFSFileSystem poifsFileSystem = null;
		
		messageErrorWwiInput = null;
		messageInfoWwiInput = null;
		String errorDataWwi = null;

		if(fileLoadWwiInput==null) return;
		
		try {
			FileInputStream  fileIn = new FileInputStream(fileLoadWwiInput.getPrearchivo() + fileLoadWwiInput.getFileName());
			poifsFileSystem = new POIFSFileSystem(fileIn);
		}
		catch (FileNotFoundException ex) {
			ex.printStackTrace();
		}
		catch (IOException ex) {
			ex.printStackTrace();
		}
		
		HSSFWorkbook workbook;
		
		generalDataLoadErrorBeanList = new ArrayList<GeneralDataLoadErrorBean>();
		
		
		try {
			workbook = new HSSFWorkbook(poifsFileSystem);
			
			getDataWwiInput(workbook, wwiInputBeanList);
			
			if (!onlyValidateData) {
				if (generalDataLoadErrorBeanList.size() == 0) {
					System.out.println("procesando datos wwi = "+wwiInputBeanList.size());
					
					errorDataWwi = dataLoadService.processWwiInputDataLoad(anio, mes, wwiInputBeanList);
					
					if(errorDataWwi==null){
						messageInfoWwiInput = MessagesView.getI18nMessage("general.validate.fileProcessed");
					}
					else{
						messageErrorWwiInput = errorDataWwi;
					}
				}
			}
			else {
				if (generalDataLoadErrorBeanList == null || generalDataLoadErrorBeanList.size() == 0) {
					System.out.println("validando datos wwi = "+wwiInputBeanList.size());
					messageInfoWwiInput = MessagesView.getI18nMessage("general.validateFile.sucessfull");
				}
			}
		}
		catch (Exception ex) {
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}
	
	
	private void getDataWwiInput(HSSFWorkbook workbook,List<BudgetInputBean> wwiInputBeanList) {
		String codigoUbigeo = null;
		String departamento = null;
		String provincia = null;
		String distrito = null;
		Long ejecutadoWwi = null;
		
		BudgetInputBean budgetInputBean = null;
		
		boolean sinContenido = false;
		
		try{
			HSSFSheet sheet = workbook.getSheetAt(0); 
			for(int i=3;i<sheet.getPhysicalNumberOfRows() && !sinContenido;i++){
				
				Row row=sheet.getRow(i);

				Cell codigoUbigeoCell = row.getCell(0);
				Cell departamentoCell = row.getCell(2);
				Cell provinciaCell = row.getCell(3);
				Cell distritoCell = row.getCell(4);
				Cell ejecutadoWwiCell = row.getCell(11);
				
				budgetInputBean = new BudgetInputBean();
				budgetInputBean.setAnio(this.anio);
				budgetInputBean.setMes(this.mes);
				
				if (codigoUbigeoCell != null && (
						codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING || 
								codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_NUMERIC)) {
					if(codigoUbigeoCell.getCellType() == Cell.CELL_TYPE_STRING){
						codigoUbigeo = codigoUbigeoCell.getStringCellValue().toUpperCase();
					}
					else{
						codigoUbigeo = getUbigeoAsString((Long.valueOf((long)codigoUbigeoCell.getNumericCellValue())));
					}
					budgetInputBean.setCodigoUbigeo(codigoUbigeo);
				}
				else{
//					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.codigoUbigeoNoExist"));
//					sinContenido = true;
//					continue;
					budgetInputBean.setCodigoUbigeo("");
				}
				
				if (departamentoCell != null && departamentoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					departamento = departamentoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDepartamento(departamento);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.departamentoNoExist"));
				}
				
				if (provinciaCell != null && provinciaCell.getCellType() == Cell.CELL_TYPE_STRING) {
					provincia = provinciaCell.getStringCellValue().toUpperCase();
					budgetInputBean.setProvincia(provincia);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.provinciaNoExist"));
				}
				
				if (distritoCell != null && distritoCell.getCellType() == Cell.CELL_TYPE_STRING) {
					distrito = distritoCell.getStringCellValue().toUpperCase();
					budgetInputBean.setDistrito(distrito);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.distritoNoExist"));
				}
				
				if (ejecutadoWwiCell != null && ejecutadoWwiCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
					ejecutadoWwi = Long.valueOf((long)ejecutadoWwiCell.getNumericCellValue());
					budgetInputBean.setEjecutadoWwi(ejecutadoWwi);
				}
				else{
					this.addErrorMessage(generalDataLoadErrorBeanList, (i+1), MessagesView.getI18nMessage("budgetReport.validate.ejecutadoWwiNoExist"));
				}
				
				wwiInputBeanList.add(budgetInputBean);

			}
		}
		catch(Exception ex){
			ex.printStackTrace();
			this.addErrorMessage(generalDataLoadErrorBeanList, 0, ex.getMessage());
		}
	}

	private void addErrorMessage(List<GeneralDataLoadErrorBean> generalDataLoadErrorBeanList, int row, String errorMessage) {
		GeneralDataLoadErrorBean generalDataLoadErrorBean = new GeneralDataLoadErrorBean();
		
		generalDataLoadErrorBean.setRowError(row);
		generalDataLoadErrorBean.setErrorDescription(errorMessage);
		generalDataLoadErrorBeanList.add(generalDataLoadErrorBean);
	}
	
	
	public void loadData(boolean onlyValidateData) {
		messageError = null;
		if(!validForm) return;
		this.readFileBudgetInput(onlyValidateData);
		this.readFileGoalsInput(onlyValidateData);
		this.readFileQatariInput(onlyValidateData);
		this.readFileWwiInput(onlyValidateData);
	}
	

	public boolean isFlagLoaded() {
		return flagLoaded;
	}

	public void setFlagLoaded(boolean flagLoaded) {
		this.flagLoaded = flagLoaded;
	}

	public ArrayList<FileLoad> getFilesBudgetInput() {
		return filesBudgetInput;
	}

	public void setFilesBudgetInput(ArrayList<FileLoad> filesBudgetInput) {
		this.filesBudgetInput = filesBudgetInput;
	}

	public int getUploadsAvailableBudgetInput() {
		return uploadsAvailableBudgetInput;
	}

	public void setUploadsAvailableBudgetInput(int uploadsAvailableBudgetInput) {
		this.uploadsAvailableBudgetInput = uploadsAvailableBudgetInput;
	}

	public String getMessageErrorBudgetInput() {
		return messageErrorBudgetInput;
	}

	public void setMessageErrorBudgetInput(String messageErrorBudgetInput) {
		this.messageErrorBudgetInput = messageErrorBudgetInput;
	}

	public String getMessageInfoBudgetInput() {
		return messageInfoBudgetInput;
	}

	public void setMessageInfoBudgetInput(String messageInfoBudgetInput) {
		this.messageInfoBudgetInput = messageInfoBudgetInput;
	}

	public FileLoad getFileLoadBudgetInput() {
		return fileLoadBudgetInput;
	}

	public void setFileLoadBudgetInput(FileLoad fileLoadBudgetInput) {
		this.fileLoadBudgetInput = fileLoadBudgetInput;
	}

	public Long getAnio() {
		return anio;
	}

	public void setAnio(Long anio) {
		this.anio = anio;
	}

	public Long getMes() {
		return mes;
	}

	public void setMes(Long mes) {
		this.mes = mes;
	}

	public List<GeneralDataLoadErrorBean> getGeneralDataLoadErrorBeanList() {
		return generalDataLoadErrorBeanList;
	}

	public void setGeneralDataLoadErrorBeanList(
			List<GeneralDataLoadErrorBean> generalDataLoadErrorBeanList) {
		this.generalDataLoadErrorBeanList = generalDataLoadErrorBeanList;
	}

	public ArrayList<FileLoad> getFilesGoalsInput() {
		return filesGoalsInput;
	}

	public void setFilesGoalsInput(ArrayList<FileLoad> filesGoalsInput) {
		this.filesGoalsInput = filesGoalsInput;
	}

	public int getUploadsAvailableGoalsInput() {
		return uploadsAvailableGoalsInput;
	}

	public void setUploadsAvailableGoalsInput(int uploadsAvailableGoalsInput) {
		this.uploadsAvailableGoalsInput = uploadsAvailableGoalsInput;
	}

	public String getMessageErrorGoalsInput() {
		return messageErrorGoalsInput;
	}

	public void setMessageErrorGoalsInput(String messageErrorGoalsInput) {
		this.messageErrorGoalsInput = messageErrorGoalsInput;
	}

	public String getMessageInfoGoalsInput() {
		return messageInfoGoalsInput;
	}

	public void setMessageInfoGoalsInput(String messageInfoGoalsInput) {
		this.messageInfoGoalsInput = messageInfoGoalsInput;
	}

	public FileLoad getFileLoadGoalsInput() {
		return fileLoadGoalsInput;
	}

	public void setFileLoadGoalsInput(FileLoad fileLoadGoalsInput) {
		this.fileLoadGoalsInput = fileLoadGoalsInput;
	}

	public ArrayList<FileLoad> getFilesQatariInput() {
		return filesQatariInput;
	}

	public void setFilesQatariInput(ArrayList<FileLoad> filesQatariInput) {
		this.filesQatariInput = filesQatariInput;
	}

	public int getUploadsAvailableQatariInput() {
		return uploadsAvailableQatariInput;
	}

	public void setUploadsAvailableQatariInput(int uploadsAvailableQatariInput) {
		this.uploadsAvailableQatariInput = uploadsAvailableQatariInput;
	}

	public String getMessageErrorQatariInput() {
		return messageErrorQatariInput;
	}

	public void setMessageErrorQatariInput(String messageErrorQatariInput) {
		this.messageErrorQatariInput = messageErrorQatariInput;
	}

	public String getMessageInfoQatariInput() {
		return messageInfoQatariInput;
	}

	public void setMessageInfoQatariInput(String messageInfoQatariInput) {
		this.messageInfoQatariInput = messageInfoQatariInput;
	}

	public FileLoad getFileLoadQatariInput() {
		return fileLoadQatariInput;
	}

	public void setFileLoadQatariInput(FileLoad fileLoadQatariInput) {
		this.fileLoadQatariInput = fileLoadQatariInput;
	}

	public ArrayList<FileLoad> getFilesWwiInput() {
		return filesWwiInput;
	}

	public void setFilesWwiInput(ArrayList<FileLoad> filesWwiInput) {
		this.filesWwiInput = filesWwiInput;
	}

	public int getUploadsAvailableWwiInput() {
		return uploadsAvailableWwiInput;
	}

	public void setUploadsAvailableWwiInput(int uploadsAvailableWwiInput) {
		this.uploadsAvailableWwiInput = uploadsAvailableWwiInput;
	}

	public String getMessageErrorWwiInput() {
		return messageErrorWwiInput;
	}

	public void setMessageErrorWwiInput(String messageErrorWwiInput) {
		this.messageErrorWwiInput = messageErrorWwiInput;
	}

	public String getMessageInfoWwiInput() {
		return messageInfoWwiInput;
	}

	public void setMessageInfoWwiInput(String messageInfoWwiInput) {
		this.messageInfoWwiInput = messageInfoWwiInput;
	}

	public FileLoad getFileLoadWwiInput() {
		return fileLoadWwiInput;
	}

	public void setFileLoadWwiInput(FileLoad fileLoadWwiInput) {
		this.fileLoadWwiInput = fileLoadWwiInput;
	}

	public ArrayList<FileLoad> getFilesSafInput() {
		return filesSafInput;
	}

	public void setFilesSafInput(ArrayList<FileLoad> filesSafInput) {
		this.filesSafInput = filesSafInput;
	}

	public int getUploadsAvailableSafInput() {
		return uploadsAvailableSafInput;
	}

	public void setUploadsAvailableSafInput(int uploadsAvailableSafInput) {
		this.uploadsAvailableSafInput = uploadsAvailableSafInput;
	}

	public String getMessageErrorSafInput() {
		return messageErrorSafInput;
	}

	public void setMessageErrorSafInput(String messageErrorSafInput) {
		this.messageErrorSafInput = messageErrorSafInput;
	}

	public String getMessageInfoSafInput() {
		return messageInfoSafInput;
	}

	public void setMessageInfoSafInput(String messageInfoSafInput) {
		this.messageInfoSafInput = messageInfoSafInput;
	}

	public FileLoad getFileLoadSafInput() {
		return fileLoadSafInput;
	}

	public void setFileLoadSafInput(FileLoad fileLoadSafInput) {
		this.fileLoadSafInput = fileLoadSafInput;
	}

	public String getMessageError() {
		return messageError;
	}

	public void setMessageError(String messageError) {
		this.messageError = messageError;
	}

	public boolean isValidForm() {
		return validForm;
	}

	public void setValidForm(boolean validForm) {
		this.validForm = validForm;
	}
    
}